using System;
using L=Science.Physics.GeneralPhysics;

namespace Serway.Chapter25
{
	/// <summary>
	/// Example02: Motion of a Proton in a Uniform Electric Field.
	/// A proton is released from rest in a uniform electric field 
	/// that has a magnitude of 8.0 \times 10^4 V/m (Fig. 25.6). 
	/// The proton undergoes a displacement of 0.50 m in the 
	/// direction of E.
	/// (A) 
	/// Find the change in electric potential between points A and B.
	/// \Delta V = -4.0 \times 10^4 V
	/// (B) 
	/// Find the change in potential energy of the proton-field 
	/// system for this displacement. 
	/// \Delta U = -6.4 \times 10^{-15} J
	/// (C) 
	/// Find the speed of the proton after completing 
	/// the 0.50 m displacement in the electric field. 
	/// v = 2.8 \times 10^6 m/s
	/// </summary>
	public class Example02
	{
		public Example02()
		{
		}
		private string result;
		public string Result
		{
			get{return result;}
		}
		public void Compute()
		{
			L.ElectricField E = new L.ElectricField();
			E.X = 8.0E4;
			L.Position A = new L.Position();
			A.X = 0.0;
			L.Position B = new L.Position();
			B.X = 0.5;
			L.ElectricPotentialDifference delV
				= new L.ElectricPotentialDifference();
			delV.V = -E.X*(B.X - A.X);
			//(A)
			result+=Convert.ToString(delV.V)+"\r\n";
			//(B)
			L.Energy U = new L.Energy();
			U.J = L.Constant.ElementaryCharge*delV.V;
			result+=Convert.ToString(U.J)+"\r\n";
			//(C)
			L.KineticEnergy Ki = new L.KineticEnergy();
			Ki.J = 0.0;
			L.KineticEnergy Kf = new L.KineticEnergy();
			Kf.VariableQ = true;
			L.Work W = new L.Work();
			W.J = -U.J;
			L.FundamentalLaw.WorkEnergyTheorem(Ki,W,Kf);
			L.Mass m = new L.Mass();
			m.kg = Science.Physics.ExperimentData.ProtonMass;
			L.Velocity v = new L.Velocity(m,Kf);
			result+=Convert.ToString(v.mPERs)+"\r\n";			
		}
	}
}
